import { getEmoji } from '@renderer/utils/emotion'
import { getImg } from '@renderer/utils'
// 创建dom
export const createDom = (type: string, info: any) => {
  switch (type) {
    case 'emoji':
      let emojiElement = document.createElement('img')
      emojiElement.className = 'emoji-normal no-text'
      emojiElement.dataset.emojiCode = info
      emojiElement.src = getEmoji(info)
      return emojiElement
    case 'image':
      let imageElement = document.createElement('img')
      imageElement.className = 'chat-image no-text'
      imageElement.src = info.url
      imageElement.dataset.imgId = info.fileId + ''
      return imageElement
    case 'file':
      let fileId = info.fileId
      let fileElement = document.createElement('div')
      fileElement.className = 'chat-file no-text'
      fileElement.contentEditable = 'false'
      fileElement.dataset.fileId = fileId
      let iconName = 'file'
      let name = info.file.name
      if (name.includes('.pdf')) {
        iconName = 'pdf'
      } else if (name.includes('.xlsx') || name.includes('.xls)')) {
        iconName = 'excel'
      } else if (name.includes('.docx') || name.includes('.doc')) {
        iconName = 'word'
      } else {
        iconName = 'file'
      }
      let domFragment = `<img class="file-icon ${iconName}" src='${getImg('img/im/' + iconName + '.png')}'></img><span class="file-name">${name}</span>`
      fileElement.innerHTML = domFragment
      return fileElement
  }
  return ''
}
export const copyToInput = () => {}
